{% extends "group/group_base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% origin %}
{% load ietf_filters static person_filters ietf_filters %}
{% block group_subtitle %}Review requests{% endblock %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
{% endblock %}
{% block group_content %}
    {% origin %}
    {% if can_access_stats %}
        <div class="float-end">
            <a href="{% url "ietf.stats.views.review_stats" %}" class="icon-link">
                <i class="bi bi-bar-chart-line"></i>
            </a>
        </div>
    {% endif %}
    <h2 class="mt-5" id="unassigned-and-open-review-requests">Unassigned and open review requests and assignments</h2>
    <table class="table table-sm table-striped tablesorter">
        <thead>
            <tr>
                <th scope="col" data-sort="request">Request</th>
                <th scope="col" data-sort="type">Type</th>
                <th scope="col" data-sort="req">Requested</th>
                <th scope="col" data-sort="deadline">Deadline</th>
                <th scope="col" data-sort="state">Document state</th>
                <th scope="col" data-sort="telechat">IESG Telechat</th>
            </tr>
        </thead>
            <tbody>
                <tr class="table-info" id="unassigned-review-requests">
                    <th scope="col" colspan="6">Unassigned review requests</th>
                </tr>
            </tbody>
            <tbody>
                {% for r in unassigned_review_requests %}
                    <tr>
                        <td>
                            {% if r.pk != None %}
                                <a href="{% url "ietf.doc.views_review.review_request" name=r.doc.name request_id=r.pk %}">
                            {% endif %}
                                {{ r.doc.name }}-{% if r.requested_rev %}{{ r.requested_rev }}{% else %}{{ r.doc.rev }}{% endif %}
                            {% if r.pk != None %}</a>{% endif %}
                            </td>
                            <td>{{ r.type.name }}</td>
                            <td>
                                {% if r.pk %}
                                    {{ r.time|date:"Y-m-d" }} by {% person_link r.requested_by %}
                                {% else %}
                                    <span class="badge rounded-pill text-bg-info">Auto-suggested</span>
                                {% endif %}
                            </td>
                            <td>
                                {{ r.deadline|date:"Y-m-d" }}
                                {% if r.due %}
                                    <span class="badge rounded-pill text-bg-warning"
                                          title="{{ r.due }} day{{ r.due|pluralize }} past deadline">{{ r.due }} day{{ r.due|pluralize }}</span>
                                {% endif %}
                            </td>
                            <td>{{ r.doc.friendly_state }}</td>
                            <td>
                                {% if r.doc.telechat_date %}{{ r.doc.telechat_date }}{% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
            <table class="table table-sm table-striped tablesorter">
                <thead>
                    <tr>
                        <th scope="col" data-sort="request">Request</th>
                        <th scope="col" data-sort="type">Type</th>
                        <th scope="col" data-sort="req">Requested</th>
                        <th scope="col" data-sort="deadline">Deadline</th>
                        <th scope="col" data-sort="reviewer">Reviewer</th>
                        <th scope="col" data-sort="state">Document state</th>
                        <th scope="col" data-sort="telechat">IESG Telechat</th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="table-info" id="open_review_assignments">
                        <th scope="col" colspan="7">Open review requests</th>
                    </tr>
                </tbody>
                <tbody>
                    {% for a in open_review_assignments %}
                        <tr>
                            <td>
                                <a href="{% url "ietf.doc.views_review.review_request" name=a.review_request.doc.name request_id=a.review_request.pk %}">
                                    {{ a.review_request.doc.name }}-{% if a.review_request.requested_rev %}{{ a.review_request.requested_rev }}{% else %}{{ a.review_request.doc.rev }}{% endif %}
                                </a>
                            </td>
                            <td>{{ a.review_request.type.name }}</td>
                            <td>{{ a.assigned_on|date:"Y-m-d" }}</td>
                            <td>
                                {{ a.review_request.deadline|date:"Y-m-d" }}
                                {% if a.due %}
                                    <span class="badge rounded-pill text-bg-warning"
                                          title="{{ a.due }} day{{ a.due|pluralize }} past deadline">{{ a.due }} day{{ a.due|pluralize }}</span>
                                {% endif %}
                            </td>
                            <td>
                                {% person_link a.reviewer.person %}
                                {{ a.state_id|badgeify }}
                            </td>
                            <td>{{ a.review_request.doc.friendly_state }}</td>
                            <td>
                                {% if a.review_request.doc.telechat_date %}{{ a.review_request.doc.telechat_date }}{% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        <h2 class="mt-5" id="closed-review-requests">Closed review requests and assignments</h2>
        <form class="closed-review-filter" action="#closed-review-requests">
            Past:
            <div class="btn-group btn-group-sm" role="group">
                {% for key, label in since_choices %}
                    <button class="btn btn-outline-primary {% if since == key %}active{% endif %}"
                            {% if key %}name="since" value="{{ key }}"{% endif %}
                            type="submit">
                        {{ label }}
                    </button>
                {% endfor %}
            </div>
        </form>
        <table class="table table-sm table-striped tablesorter">
            <thead>
                <tr>
                    <th scope="col" data-sort="request">Request</th>
                    <th scope="col" data-sort="type">
                        Type
                    </th>
                    <th scope="col" data-sort="req">
                        Requested
                    </th>
                    <th scope="col" data-sort="deadline">
                        Deadline
                    </th>
                    <th scope="col" data-sort="closed">
                        Closed
                    </th>
                    <th scope="col" data-sort="state">
                        State
                    </th>
                </tr>
            </thead>
                <tbody>
                    <tr class="table-info">
                        <th scope="col" colspan="6">
                            Closed review requests
                        </th>
                    </tr>
                </tbody>
                <tbody>
                    {% for r in closed_review_requests %}
                        <tr>
                            <td>
                                <a href="{% url "ietf.doc.views_review.review_request" name=r.doc.name request_id=r.pk %}">
                                    {{ r.doc.name }}{% if r.requested_rev %}-{{ r.requested_rev }}{% endif %}
                                </a>
                            </td>
                            <td>
                                {{ r.type }}
                            </td>
                            <td>
                                {{ r.time|date:"Y-m-d" }}
                                {% if r.requested_by.id != 1 %}
                                    by {% person_link r.requested_by %}
                                {% endif %}
                            </td>
                            <td>
                                {{ r.deadline|date:"Y-m-d" }}
                            </td>
                            <td>
                                {{ r.request_closed_time|date:"Y-m-d" }}
                            </td>
                            <td>
                                {{ r.state.name|badgeify }}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
            <table class="table table-sm table-striped tablesorter">
                <thead>
                    <tr>
                        <th scope="col" data-sort="request">Request</th>
                        <th scope="col" data-sort="type">
                            Type
                        </th>
                        <th scope="col" data-sort="assgn">
                            Assigned
                        </th>
                        <th scope="col" data-sort="deadline">
                            Deadline
                        </th>
                        <th scope="col" data-sort="closed">
                            Closed
                        </th>
                        <th scope="col" data-sort="reviewer">
                            Reviewer
                        </th>
                        <th scope="col" data-sort="state">
                            State
                        </th>
                        <th scope="col" data-sort="result">
                            Result
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="table-info">
                        <th scope="col" colspan="8">
                            Closed review assignments
                        </th>
                    </tr>
                </tbody>
                <tbody>
                    {% for a in closed_review_assignments %}
                        <tr>
                            <td>
                                <a href="{% url "ietf.doc.views_review.review_request" name=a.review_request.doc.name request_id=a.review_request.pk %}">
                                    {{ a.review_request.doc.name }}{% if a.review_request.requested_rev %}-{{ a.review_request.requested_rev }}{% endif %}
                                </a>
                            </td>
                            <td>
                                {{ a.review_request.type }}
                            </td>
                            <td>
                                {{ a.assigned_on|date:"Y-m-d" }}
                            </td>
                            <td>
                                {{ a.review_request.deadline|date:"Y-m-d" }}
                            </td>
                            <td>
                                {{ a.completed_on|date:"Y-m-d" }}
                            </td>
                            <td>
                                {% person_link a.reviewer.person %}
                            </td>
                            <td>
                                {{ a.state|badgeify }}
                            </td>
                            <td>
                                {% if a.result %}{{ a.result|badgeify }}{% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
        </table>
    {% endblock %}
    {% block js %}
        <script src="{% static "ietf/js/list.js" %}">
        </script>
    {% endblock %}